package com.ruoyi.web.controller.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.api.WTransferCollect;
import com.ruoyi.system.service.IWTransferCollectService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 归集记录Controller
 * 
 * @author ruoyi
 * @date 2022-04-22
 */
@RestController
@RequestMapping("/api/wTransferCollect")
public class WTransferCollectController extends BaseController
{
    @Autowired
    private IWTransferCollectService wTransferCollectService;

    /**
     * 查询归集记录列表
     */
    @PreAuthorize("@ss.hasPermi('api:wTransferCollect:list')")
    @GetMapping("/list")
    public TableDataInfo list(WTransferCollect wTransferCollect)
    {
        startPage();
        List<WTransferCollect> list = wTransferCollectService.selectWTransferCollectList(wTransferCollect);
        return getDataTable(list);
    }

    /**
     * 导出归集记录列表
     */
    @PreAuthorize("@ss.hasPermi('api:wTransferCollect:export')")
    @Log(title = "归集记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WTransferCollect wTransferCollect)
    {
        List<WTransferCollect> list = wTransferCollectService.selectWTransferCollectList(wTransferCollect);
        ExcelUtil<WTransferCollect> util = new ExcelUtil<WTransferCollect>(WTransferCollect.class);
        util.exportExcel(response, list, "归集记录数据");
    }

    /**
     * 获取归集记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('api:wTransferCollect:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wTransferCollectService.selectWTransferCollectById(id));
    }

    /**
     * 新增归集记录
     */
    @PreAuthorize("@ss.hasPermi('api:wTransferCollect:add')")
    @Log(title = "归集记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WTransferCollect wTransferCollect)
    {
        return toAjax(wTransferCollectService.insertWTransferCollect(wTransferCollect));
    }

    /**
     * 修改归集记录
     */
    @PreAuthorize("@ss.hasPermi('api:wTransferCollect:edit')")
    @Log(title = "归集记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WTransferCollect wTransferCollect)
    {
        return toAjax(wTransferCollectService.updateWTransferCollect(wTransferCollect));
    }

    /**
     * 删除归集记录
     */
    @PreAuthorize("@ss.hasPermi('api:wTransferCollect:remove')")
    @Log(title = "归集记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wTransferCollectService.deleteWTransferCollectByIds(ids));
    }
}
